#pragma once
#include <vector>
#include "audionode.h"
#include <cmath>

using namespace std;

class COrgan :
    public CAudioNode
{
public:
    COrgan(void);
    ~COrgan(void);

public:
    virtual void Start();
    virtual bool Generate();

    void SetFreq(double f) {m_freq = f;}
    void SetAmplitude(double a) {m_amp = a;}
	void SetDuration(double d) {m_duration = d * GetSampleRate();}
	void SetDrawbars(vector<double> drawbars) {m_drawbars = drawbars;}

	void SetVibratoFreq(double VibratoF) {m_VibratoFrequency = VibratoF;}
	void SetVibratoMag(double VibratoM) {m_VibratoMagnitude = VibratoM;}	

	void SetLeslieFreq(double LeslieF) {m_LeslieFrequency = LeslieF;}
	void SetLeslieEndFreq(double LeslieEF) {m_LeslieEndFrequency = LeslieEF;}
	void SetLeslieStartFreq(double LeslieSF) {m_LeslieStartFrequency = LeslieSF;}
	void SetLeslieRadius(double LeslieR) {m_LeslieRadius = LeslieR;}
	void SetLeslieAttackTime(double LeslieAT) {m_LeslieAttackTime = LeslieAT;}
	void SetLeslieReleaseTime(double LeslieRT) {m_LeslieReleaseTime = LeslieRT;}
	void SetLeslieChanged(bool LeslieC) {m_LeslieChanged = LeslieC;}

private:
    vector<double> m_drawbars;
	double m_freq;
    double m_phase;
    double m_amp;
	double m_duration;
	double m_time;
	
	vector<int> m_harmonics;
	double m_VibratoFrequency;
	double m_VibratoMagnitude;
	double m_VibratoPhase;

	double m_LeslieFrequency;
	double m_LeslieStartFrequency;
	double m_LeslieEndFrequency;
	double m_LeslieAttackTime;
	double m_LeslieReleaseTime;
	double m_LeslieRadius;
	bool m_LeslieChanged;
	double m_LesliePhase;
};

